LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads EitherT

Contents

record EitherT <L, M, A> (K<M, Either<L, A>> runEither) Source #

where M : Monad<M>

EitherT monad transformer, which allows for an optional result.

Parameters

type M

Given monad trait

type L

Left value type

type A

Bound value type

param runEither

Transducer that represents the transformer operation

Properties

property K<M, bool> IsRight Source #

Is the EitherT in a Right state?

property K<M, bool> IsLeft Source #

Is the EitherT in a Left state?

Methods

method EitherT<L, M, A> Right (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

EitherT

method EitherT<L, M, A> Left (L value) Source #

Lift a fail value into the monad-transformer

Parameters

param value

Value to lift

returns

EitherT

method EitherT<L, M, A> Lift (Pure<A> pure) Source #

Lifts a given monad into the transformer

Parameters

param pure

Monad to lift

returns

EitherT

method EitherT<L, M, A> Lift (Either<L, A> either) Source #

Lifts a given monad into the transformer

Parameters

param either

Monad to lift

returns

EitherT

method EitherT<L, M, A> Lift (Fail<L> fail) Source #

Lifts a given monad into the transformer

Parameters

param fail

Monad to lift

returns

EitherT

method EitherT<L, M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, A> Lift (K<M, Either<L, A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, A> LiftIO (IO<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method EitherT<L, M, A> LiftIO (IO<Either<L, A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

EitherT

method K<M, B> Match <B> (Func<L, B> Left, Func<A, B> Right) Source #

Invokes the Right or Left function depending on the state of the Either

Parameters

type B

Return type

param Left

Function to invoke if in a Left state

param Right

Function to invoke if in a Right state

returns

The return value of the invoked function

method K<M, Unit> Match (Action<L> Left, Action<A> Right) Source #

Invokes the Right or Left action depending on the state of the Either

Parameters

param Right

Action to invoke if in a Right state

param Left

Action to invoke if in a Left state

returns

Unit

method K<M, A> IfLeft (Func<A> Left) Source #

Executes the Left function if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param Left

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, A> IfLeft (Func<L, A> leftMap) Source #

Executes the leftMap function if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param leftMap

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, A> IfLeft (A rightValue) Source #

Returns the rightValue if the Either is in a Left state. Returns the Right value if the Either is in a Right state.

Parameters

param rightValue

Value to return if in the Left state

returns

Returns an unwrapped Right value

method K<M, Unit> IfLeft (Action<L> Left) Source #

Executes the Left action if the Either is in a Left state.

Parameters

param Left

Function to generate a Right value if in the Left state

returns

Returns an unwrapped Right value

method K<M, Unit> IfRight (Action<A> Right) Source #

Invokes the Right action if the Either is in a Right state, otherwise does nothing

Parameters

param Right

Action to invoke

returns

Unit

method K<M, L> IfRight (L leftValue) Source #

Returns the leftValue if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param leftValue

Value to return if in the Left state

returns

Returns an unwrapped Left value

method K<M, L> IfRight (Func<L> Right) Source #

Returns the result of Right() if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param Right

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method K<M, L> IfRight (Func<A, L> rightMap) Source #

Returns the result of rightMap if the Either is in a Right state. Returns the Left value if the Either is in a Left state.

Parameters

param rightMap

Function to generate a Left value if in the Right state

returns

Returns an unwrapped Left value

method K<M, Either<L, A>> Run () Source #

Runs the EitherT exposing the outer monad with an inner wrapped Either

method EitherT<L, M1, B> MapT <M1, B> (Func<K<M, Either<L, A>>, K<M1, Either<L, B>>> f) Source #

where M1 : Monad<M1>

Maps the bound monad

Parameters

type M1

Target monad type

type B

Target bound value type

param f

Mapping function

returns

Mapped monad

method EitherT<L, M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

method EitherT<L, M, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, K<EitherT<L, M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, Either<L, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, EitherT<L, M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, Pure<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, B> Bind <B> (Func<A, Fail<L>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, K<EitherT<L, M>, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, EitherT<L, M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, Either<L, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method OptionT<M, A> ToOption () Source #

class EitherTExt Source #

Either monad extensions

Methods

method EitherT<L, M, A> As <L, M, A> (this K<EitherT<L, M>, A> ma) Source #

where M : Monad<M>

method EitherT<L, IO, A> Flatten <L, A> (this Task<EitherT<L, IO, A>> tma) Source #

Get the outer task and wrap it up in a new IO within the EitherT IO

method EitherT<L, IO, A> ToIO <L, A> (this Task<Either<L, A>> ma) Source #

Lift the task

method EitherT<L, M, A> Flatten <L, M, A> (this EitherT<L, M, EitherT<L, M, A>> mma) Source #

where M : Monad<M>

Monadic join

method EitherT<L, M, C> SelectMany <L, M, A, B, C> ( this K<M, A> ma, Func<A, K<EitherT<L, M>, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, C> SelectMany <L, M, A, B, C> ( this K<M, A> ma, Func<A, EitherT<L, M, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

EitherT

method EitherT<L, M, B> Apply <L, M, A, B> (this EitherT<L, M, Func<A, B>> mf, EitherT<L, M, A> ma) Source #

where M : Monad<M>

Applicative apply

method EitherT<L, M, B> Action <L, M, A, B> (this EitherT<L, M, A> ma, EitherT<L, M, B> mb) Source #

where M : Monad<M>

Applicative action

method K<M, Seq<L>> Lefts <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Left' elements. All the 'Left' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<L>> Lefts <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Left' elements. All the 'Left' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<R>> Rights <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Right' elements. All the 'Right' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, Seq<R>> Rights <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Extracts from a list of 'Either' all the 'Right' elements. All the 'Right' elements are extracted in order.

Parameters

type L

Left

type R

Right

param self

Either list

returns

An enumerable of L

method K<M, (Seq<L> Lefts, Seq<R> Rights)> Partition <L, M, R> (this Seq<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Partitions a list of 'Either' into two lists. All the 'Left' elements are extracted, in order, to the first component of the output. Similarly the 'Right' elements are extracted to the second component of the output.

Parameters

type L

Left

type R

Right

param self

Either list

returns

A tuple containing the an enumerable of L and an enumerable of R

method K<M, (Seq<L> Lefts, Seq<R> Rights)> Partition <L, M, R> (this IEnumerable<EitherT<L, M, R>> self) Source #

where M : Monad<M>

Partitions a list of 'Either' into two lists. All the 'Left' elements are extracted, in order, to the first component of the output. Similarly the 'Right' elements are extracted to the second component of the output.

Parameters

type L

Left

type R

Right

param self

Either list

returns

A tuple containing the an enumerable of L and an enumerable of R

class EitherT <L, M> Source #

Methods

method EitherT<L, M, A> Right <A> (A value) Source #

method EitherT<L, M, A> Left <A> (L value) Source #

method EitherT<L, M, A> lift <A> (Either<L, A> ma) Source #

method EitherT<L, M, A> lift <A> (Pure<A> ma) Source #

method EitherT<L, M, A> lift <A> (Fail<L> ma) Source #

method EitherT<L, M, A> liftIO <A> (IO<A> ma) Source #

class EitherT Source #

Methods

method EitherT<L, M, B> bind <L, M, A, B> (EitherT<L, M, A> ma, Func<A, EitherT<L, M, B>> f) Source #

where M : Monad<M>

method EitherT<L, M, B> map <L, M, A, B> (Func<A, B> f, EitherT<L, M, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> Right <L, M, A> (A value) Source #

where M : Monad<M>

method EitherT<L, M, A> Left <L, M, A> (L value) Source #

where M : Monad<M>

method EitherT<L, M, B> apply <L, M, A, B> (EitherT<L, M, Func<A, B>> mf, EitherT<L, M, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, B> action <L, M, A, B> (EitherT<L, M, A> ma, EitherT<L, M, B> mb) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Either<L, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (K<M, A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Pure<A> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> lift <L, M, A> (Fail<L> ma) Source #

where M : Monad<M>

method EitherT<L, M, A> liftIO <L, M, A> (IO<A> ma) Source #

where M : Monad<M>

method K<M, B> match <L, M, A, B> (EitherT<L, M, A> ma, Func<L, B> Left, Func<A, B> Right) Source #

where M : Monad<M>

class EitherT <L, M> Source #

where M : Monad<M>

Trait implementation for EitherT

Parameters

type M

Given monad trait